<template>
	<view class="wrap">
		<block v-if="currType == 'addInfo' || currType == 'editInfo'">
			<view class="modItem spaceBet">
				<view class="modTit">团体名称</view>
				<view class="modCon hasFlex">
					<input class="modInp" type="text" v-model="groupName" placeholder="请输入团体名称" maxlength="30"/>
				</view>
			</view>
			<view class="modItem spaceBet">
				<view class="modTit">负责人姓名</view>
				<view class="modCon hasFlex">
					<input class="modInp" type="text" v-model="userName" placeholder="请输入团体负责人姓名" maxlength="6"/>
				</view>
			</view>
			<view class="modItem spaceBet">
				<view class="modTit">联系方式</view>
				<view class="modCon hasFlex">
					<input class="modInp" type="tel" v-model="phoneNum" maxlength="11" placeholder="请输入负责人手机号码"/>
				</view>
			</view>
		</block>
		<block v-else>
			<view class="modItem spaceBet">
				<view class="modTit">团体人数</view>
				<view class="modCon hasFlex">
					<input class="modInp" type="tel" v-model="groupNum" maxlength="5" placeholder="请设置团体人数"/>
				</view>
			</view>
		</block>
		<button class="comBtn hasBotFixed noBorRad" @tap="saveInfo">保存信息</button>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				groupName:'',
				userName:'',
				phoneNum:'',
				groupNum:'',
				currType:''
			}
		},
		onLoad(options){
			this.currType = options.currType;
		},
		methods:{
			saveInfo(){
				if(this.currType == 'addInfo' || this.currType == 'editInfo'){
					if(this.groupName == ''){
						this.util.showToast('团体名称不能为空');
					}else if(this.userName == ''){
						this.util.showToast('团体负责人姓名不能为空');
					}else if(this.phoneNum == ''){
						this.util.showToast('负责人手机号码不能为空');
					}else if(!this.regX.regPhone.test( this.phoneNum )){
						this.util.showToast('手机号码格式不对');
					}else{
						let pages = getCurrentPages();
						let prevPage = pages[pages.length - 2];
						prevPage.$vm.groupName = this.groupName;
						prevPage.$vm.groupPerson = this.userName;
						prevPage.$vm.groupPhone = this.phoneNum;
						prevPage.$vm.hasGroupFlag = true;
						uni.navigateBack({
							delta:1
						})
					}
				}else{
					if(this.groupNum == ''){
						this.util.showToast('团体人数不能为空');
					}else if(!this.regX.regNumNotZero.test( this.groupNum )){
						this.util.showToast('团体人数应为大于0的正整数');
					}else if(this.groupNum > 50000){
						this.util.showToast('团体人数最大值不能超过50000人');
					}else{
						let pages = getCurrentPages();
						let prevPage = pages[pages.length - 2];
						prevPage.$vm.setNums = this.groupNum + '人';
						prevPage.$vm.num = this.groupNum;
						uni.navigateBack({
							delta:1
						})
					}
				}
			}
		}
	}
</script>

<style lang='scss'>
	.comBtn{
		margin-top: 160rpx;
		border-radius: 50rpx;
	}
	.modItem{
		height: 100rpx;
		line-height: 100rpx;
		border-radius: 10rpx;
		background: #fff;
		padding:0 20rpx;
		margin-bottom: 30rpx;
		.modTit{
			width: 160rpx;
			height: 100%;
			font-size: $font-size32;
			color: $pss-text-color3;
		}
		.modCon{
			width:75%;
			justify-content: flex-end;
			.modInp{
				width: 97%;
				height: 100%;
				font-size: $font-size30;
				color: $pss-text-color3;
				text-align: right;
				padding-right: 3%;
			}
			.pickerView{
				width: 280rpx;
				height: 100%;
				font-size: $font-size30;
				color: $pss-text-color3;
				justify-content: flex-end;
				.pickerTxt{
					color: $pss-text-color8;
					&.hasSelCol{
						color: $pss-text-color3;
					}
				}
				.icon-sanjiao{
					color: $pss-text-colora;
					font-size: 46rpx;
					margin-left: 15rpx;
				}
			}
		}
	}
	.wrap{
		padding: 30rpx 30rpx 0;
	}
	page{
		background: $pss-bg-primary;
	}
</style>